import maya.cmds as mc
import Modular_facial_rig.mouth_build.mouth_temple
reload(Modular_facial_rig.mouth_build.mouth_temple)

import Modular_facial_rig.head_stretch_build.head_stretcj_setting
reload(Modular_facial_rig.head_stretch_build.head_stretcj_setting)

import LZ_public_command.LZ_UI
reload(LZ_public_command.LZ_UI)

import Modular_facial_rig.eyeBrow_build.eyeBrow_setting
reload(Modular_facial_rig.eyeBrow_build.eyeBrow_setting)

import Modular_facial_rig.nose_build.nose_setting_builde
reload(Modular_facial_rig.nose_build.nose_setting_builde)

import Modular_facial_rig.eye_setting.createEyeSetting
reload(Modular_facial_rig.eye_setting.createEyeSetting)

import Modular_facial_rig.singgle_setting_build.singgle_setting_build
reload(Modular_facial_rig.singgle_setting_build.singgle_setting_build)


import Modular_facial_rig.Tools.reset_mouthCtrl_position as reset_mouthCtrl_position
reload(reset_mouthCtrl_position)

class facial_rig_UI(Modular_facial_rig.mouth_build.mouth_temple.mouth_temple_build,
                    LZ_public_command.LZ_UI.LZ_UI,
                    Modular_facial_rig.head_stretch_build.head_stretcj_setting.head_stretch_setting,
                    Modular_facial_rig.eyeBrow_build.eyeBrow_setting.eyeBrow_setting,
                    Modular_facial_rig.nose_build.nose_setting_builde.nose_setting_build,
                    Modular_facial_rig.eye_setting.createEyeSetting.createEyeSetting,
                    Modular_facial_rig.singgle_setting_build.singgle_setting_build.singgle_setting_build,
                    reset_mouthCtrl_position.reset_mouthCtrl_positon
                    ):
    def __init__(self):
        Modular_facial_rig.mouth_build.mouth_temple.mouth_temple_build.__init__(self)
        pass
    def Modular_facial_Win(self):
        mdlar_facial_rig_UI = 'mdlar_facial_rig_UI'
        if mc.window(mdlar_facial_rig_UI,ex = True):
            mc.deleteUI(mdlar_facial_rig_UI)
            
        mc.window(mdlar_facial_rig_UI,widthHeight=(350, 400),t='mdlar_facial_rig_UI',menuBar = True,rtf=True,s=True)
     
        
        
        main = mc.columnLayout('mdlar_facial_Sys_main',columnAttach=('both', 5), rowSpacing=10, columnWidth=350 )
        
        mc.frameLayout( 'loadBaseModel_frameLY',label='Base_Models', borderStyle='in',collapsable=False,bgc =(0.1,0.1,0.1) ,font = 'boldLabelFont')
        
        ##
        mc.rowLayout( 'head_model_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'head_model :  ')
        mc.textField( 'head_model_textField',text='' )
        mc.button('load_headModel' ,c = lambda *args:self.loadHeadMesh() )
        mc.setParent('loadBaseModel_frameLY')
        
        ##
        mc.rowLayout( 'lips_prefix_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'charator_prefix  :  ')
        mc.textField( 'charator_prefix_textField',text='' )
        mc.setParent('loadBaseModel_frameLY')
    
    
        
        '''
        =========================================================
        ||                                                     ||
        ||                                                     ||
        ||                                                     ||
        ||                                                     ||
        =========================================================
        
        
        
        '''
        mc.setParent( main )
        mc.frameLayout( 'headstretch_setting_frameLY',collapse = 1,label='headStretch_settings', borderStyle='in',collapsable=True,bgc =(0.1,0.1,0.1) ,font = 'boldLabelFont')
        mc.separator( style='none' )

        
        mc.button('  import Stretch temple   ',h=35,bgc=(0.75,0.2,0.5), c = lambda *args:self.importStretch_temple())
        
        mc.frameLayout( 'headStretch_temloc_frameLY',collapse = 1 ,label='headStretch_temlocs  (click here if you want to modify)', borderStyle='in',collapsable=True,bgc =(0.3,0.1,0.25) ,font = 'boldLabelFont')
        
        ##
        mc.rowLayout( 'headStretch_up_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'headStretch_up_temLoc  :  ')
        mc.textField( 'headStretch_up_temLoc_textField',text='ac_cn_upperhead_templeac_cn_midhead_temple' )
        mc.button('load_upper' ,bgc =(0.3,0.1,0.25),c = lambda *args:self.loadTextField( 'headStretch_up_temLoc_textField' ) )
        mc.setParent('headStretch_temloc_frameLY')
        
        ##
        mc.rowLayout( 'headStretch_low_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'headStretch_low_temLoc  :  ')
        mc.textField( 'headStretch_low_temLoc_textField',text='ac_cn_midheadlow_templeac_cn_lowerhead_temple' )
        mc.button('load_lower' ,bgc =(0.3,0.1,0.25),c = lambda *args:self.loadTextField( 'headStretch_low_temLoc_textField' ) )
        mc.setParent('headStretch_temloc_frameLY')
        
        ###--------------------------------
        
        mc.setParent('headstretch_setting_frameLY' )
        mc.separator( style='in' )
        mc.button('  build head stretch  ',h=30,bgc=(0.75,0.2,0.5), c = lambda *args:self.buildHeadStretch_setting())
        
        
        '''
        =========================================================
        ||                                                     ||
        ||                                                     ||
        ||                                                     ||
        ||                                                     ||
        =========================================================
        
        
        
        '''
        mc.setParent( main )
        mc.frameLayout( 'eyeBrown_setting_frameLY',collapse = 1,label='eyeBrown_settings', borderStyle='in',collapsable=True,bgc =(0.1,0.1,0.1) ,font = 'boldLabelFont')
        mc.separator( style='none' )

        
        mc.button('  import eyeBrow temple (update Reference Curve)  ',h=35,bgc=(0.2,0.7,0.1), c = lambda *args:self.importEyeBrow_temloc())
        
        mc.frameLayout( 'eyeBrow_temloc_frameLY',collapse = 1 ,label='headStretch_temlocs  (click here if you want to modify)', borderStyle='in',collapsable=True,bgc =(0.1,0.4,0.0) ,font = 'boldLabelFont')
        
        ##
        mc.rowLayout( 'eyeBrow_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'eyeBrow  :  ')
        mc.textField( 'eyeBrow_temLoc_textField',text='ac_lf_eyebrow6_temloc ac_lf_eyebrow5_temloc ac_lf_eyebrow4_temloc ac_lf_eyebrow3_temloc ac_lf_eyebrow2_temloc ac_lf_eyebrow1_temloc ac_rt_eyebrow1_temloc ac_rt_eyebrow2_temloc ac_rt_eyebrow3_temloc ac_rt_eyebrow4_temloc ac_rt_eyebrow5_temloc ac_rt_eyebrow6_temloc' )
        mc.button('load_eyeBrow' ,bgc =(0.1,0.4,0.0),c = lambda *args:self.loadTextField( 'eyeBrow_temLoc_textField' ) )
        mc.setParent('eyeBrow_temloc_frameLY')
        
        ##
        mc.rowLayout( 'eyeBrow_center_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'eyeBrow_center :  ')
        mc.textField( 'eyeBrow_center_temLoc_textField',text='ac_cn_eyebrow_temloc' )
        mc.button('load_center' ,bgc =(0.1,0.4,0.0),c = lambda *args:self.loadTextField( 'eyeBrow_center_temLoc_textField' ) )
        mc.setParent('eyeBrow_temloc_frameLY')
        
        ##
        mc.rowLayout( 'eyeBrow_curveReference_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'curveReference :  ')
        mc.textField( 'curveReference_textField',text='eyeBrow_reference_curve' )
        mc.button('load_curveReference' ,bgc =(0.1,0.4,0.0),c = lambda *args:self.loadTextField( 'curveReference_textField' ) )
        mc.setParent('eyeBrow_temloc_frameLY')
        
        ###--------------------------------
        
        
        mc.setParent('eyeBrown_setting_frameLY' )
        mc.separator( style='in' )
        mc.button('  mirror TemLocs  ',h=30,bgc=(0.2,0.7,0.1), c = lambda *args:self.mirror_eyeBrow_temloc())
        
        mc.setParent('eyeBrown_setting_frameLY' )
        mc.separator( style='in' )
        mc.button('  build eyeBrow  ',h=30,bgc=(0.2,0.7,0.1), c = lambda *args:self.build_eyeBrow_setting())
        
        mc.setParent('eyeBrown_setting_frameLY' )
        mc.separator( style='in' )
        mc.button('import_rotateCenter_locator',h=30,bgc=(0.2,0.7,0.1), c = lambda *args:self.importCenterLoc())
        
        mc.setParent('eyeBrown_setting_frameLY' )
        mc.separator( style='in' )
        mc.button('update_addRotate',h=30,bgc=(0.2,0.7,0.1), c = lambda *args:self.update_addRotate())
        
        '''
        =========================================================
        ||                                                     ||
        ||                                                     ||
        ||                  eye                                ||
        ||                                                     ||
        =========================================================
        
        
        
        '''
        mc.setParent( main )
        mc.frameLayout( 'eye_setting_frameLY',collapse = 1,label='eye_settings', borderStyle='in',collapsable=True,bgc =(0.1,0.1,0.1) ,font = 'boldLabelFont')
        mc.separator( style='none' )

        #mc.checkBox( 'eye_mirror', label=' IF mirror ' ,value = 1  )  #,align ='center' 
        
        mc.radioButtonGrp( 'eye_setting_RBG',label='local :',columnWidth5 = [ 50,5,50,5,50], labelArray3=['left', 'right', 'both'], numberOfRadioButtons=3 ,sl = 3 )
        mc.radioButtonGrp( 'eye_setting_RBG',e=True,columnWidth = [1,50]  )
        #mc.checkBox( 'eye_mirror',e=True ,align ='center'  )
        mc.button('import_eye_temple (update Reference Curve) ',h=35,bgc=(0.8,0.1,0.1), c = lambda *args:self.createTemple_eye())
       
        
        
        mc.frameLayout( 'eye_temloc_frameLY',collapse = 1 ,label='eye_temlocs  (click here if you want to modify)', borderStyle='in',collapsable=True,bgc =(0.5,0.1,0.1) ,font = 'boldLabelFont')
        
        ##
        mc.rowLayout( 'eye_mirrorFix_rowLY',numberOfColumns=4,columnWidth4=(60, 95,60,95), adjustableColumn=4, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'Org_text  :  ')
        mc.textField( 'eye_Org_text_textField',text='lf_' )
        mc.text(  '  replace  :  ')
        mc.textField( 'eye_replace_textField',text='rt_' )
        mc.setParent('eye_temloc_frameLY')
        
        ##
        mc.rowLayout( 'eye_socket_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'eye_socket  :  ')
        mc.textField( 'eye_socket_temLoc_textField',text='ac_lf_innersocket_temloc ac_lf_uppersocket1_temloc ac_lf_uppersocket2_temloc ac_lf_uppersocket3_temloc ac_lf_outersocket_temloc ac_lf_lowersocket3_temloc ac_lf_lowersocket2_temloc ac_lf_lowersocket1_temloc' )
        mc.button('load_eye_socket' ,bgc =(0.5,0.1,0.1),c = lambda *args:self.loadTextField( 'eye_socket_temLoc_textField' ) )
        mc.setParent('eye_temloc_frameLY')
        
        ##
        mc.rowLayout( 'eye_upperlid_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'eye_upperlid :  ')
        mc.textField( 'eye_upperlid_temLoc_textField',text='ac_lf_upperlid1_temloc ac_lf_upperlid2_temloc ac_lf_upperlid3_temloc' )
        mc.button('load_eye_upperlid' ,bgc =(0.5,0.1,0.1),c = lambda *args:self.loadTextField( 'eye_upperlid_temLoc_textField' ) )
        mc.setParent('eye_temloc_frameLY')
        
        ##
        mc.rowLayout( 'eye_lowerlid_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'eye_lowerlid  :  ')
        mc.textField( 'eye_lowerlid_textField',text='ac_lf_lowerlid1_temloc ac_lf_lowerlid2_temloc ac_lf_lowerlid3_temloc' )
        mc.button('load_eye_lowerlid' ,bgc =(0.5,0.1,0.1),c = lambda *args:self.loadTextField( 'eye_lowerlid_textField' ) )
        mc.setParent('eye_temloc_frameLY')
        
        ##
        mc.rowLayout( 'inn_eye_conner_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'inn_eye_conner  :  ')
        mc.textField( 'inn_eye_conner_textField',text='ac_lf_innerlid_temloc' )
        mc.button('load_inn_eye_conner' ,bgc =(0.5,0.1,0.1),c = lambda *args:self.loadTextField( 'inn_eye_conner_textField' ) )
        mc.setParent('eye_temloc_frameLY')
        
        ##
        mc.rowLayout( 'out_eye_conner_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'out_eye_conner:  ')
        mc.textField( 'out_eye_conner_textField',text='ac_lf_outerlid_temloc' )
        mc.button('load_out_eye_conner' ,bgc =(0.5,0.1,0.1),c = lambda *args:self.loadTextField( 'out_eye_conner_textField' ) )
        mc.setParent('eye_temloc_frameLY')
        
        ##
        mc.rowLayout( 'eye_conter_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'eye_conter:  ')
        mc.textField( 'eye_conter_textField',text='ac_lf_eye_temloc' )
        mc.button('load_eye_conter' ,bgc =(0.5,0.1,0.1),c = lambda *args:self.loadTextField( 'eye_conter_textField' ) )
        mc.setParent('eye_temloc_frameLY')
        
        ##
        mc.rowLayout( 'eye_caimValue_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'aimValue:  ')
        mc.floatField( 'eye_aimValue_floatField', minValue = 1.0, value = 50 )
        #mc.button('load_eye_conter' ,bgc =(0.5,0.1,0.1),c = lambda *args:self.loadTextField( 'eye_conter_textField' ) )
        mc.setParent('eye_temloc_frameLY')
        
        ##
        mc.rowLayout( 'eye_eyecrunch_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'eye_eyecrunch:  ')
        mc.textField( 'eye_eyecrunch_textField',text='ac_lf_eyecrunch_temloc' )
        mc.button('load_eye_eyecrunch' ,bgc =(0.5,0.1,0.1),c = lambda *args:self.loadTextField( 'eye_eyecrunch_textField' ) )
        mc.setParent('eye_temloc_frameLY')
        ###--------------------------------
        
        
        mc.setParent('eye_setting_frameLY' )
        
        mc.radioButtonGrp( 'eye_mirrorTempleLoc_RBG',label='mirrror :',columnWidth5 = [ 50,5,50,5,50], labelArray2=['L >> R', 'R >> L'], numberOfRadioButtons=2 ,sl = 1 )
        mc.radioButtonGrp( 'eye_mirrorTempleLoc_RBG',e=True,columnWidth = [1,50]  )
        
        mc.separator( style='in' )
        mc.button('  mirror TemLocs  ',h=30,bgc=(0.8,0.1,0.1), c = lambda *args:self.mdlar_eye_mirror())
        
        mc.setParent('eye_setting_frameLY' )
        mc.separator( style='in' )
        mc.button('  build eye',h=30,bgc=(0.8,0.1,0.1), c = lambda *args:self.eye_setting_build())
        
        mc.button('  build eyeAim ctrl',h=30,bgc=(0.8,0.1,0.1), c = lambda *args:self.createEyeAimCtrl())
        
        #mc.setParent('eye_setting_frameLY' )
        #mc.separator( style='in' )
        #mc.button('solveDoubleTransform',l='solve_double_transform',h=30,bgc=(0.8,0.1,0.1), c = lambda *args:self.eye_setting_build())
        
        '''
        =========================================================
        ||                                                     ||
        ||                    mouth                            ||
        ||                                                     ||
        ||                                                     ||
        =========================================================
        
        
        
        '''
        
        mc.setParent( main )
        mc.frameLayout( 'mouth_setting_frameLY',label='mouth_settings',collapse = 1, borderStyle='in',collapsable=True,bgc =(0.1,0.1,0.1) ,font = 'boldLabelFont')
        ######
        
        
        
        mc.separator( style='none' )
        mc.button('  import Temple Locator  ',h=35,bgc=(0.75,0.75,0.3), c = lambda *args:self.createTemploc_forUI())
        '''
        
        
        '''
        mc.frameLayout( 'mouth_temloc_frameLY',collapse = 1 ,label='mouth_temlocs  (click here if you want to modify)', borderStyle='in',collapsable=True,bgc =(0.4,0.35,0) ,font = 'boldLabelFont')
        
        
        ##
        mc.rowLayout( 'uplid_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'uplid_temLoc  :  ')
        mc.textField( 'uplid_temLoc_textField',text='ac_lf_uplip1_temloc ac_lf_uplip2_temloc ac_rt_uplip1_temloc ac_rt_uplip2_temloc ac_cn_uplip_temloc' )
        mc.button('load_uplid' ,bgc =(0.4,0.35,0),c = lambda *args:self.loadTextField( 'uplid_temLoc_textField' ) )
        mc.setParent('mouth_temloc_frameLY')
        ##
        mc.rowLayout( 'lowlid_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'lowlid_temLoc  :  ')
        mc.textField( 'lowlid_temLoc_textField',text='ac_lf_lowlip1_temloc ac_rt_lowlip1_temloc ac_lf_lowlip2_temloc ac_rt_lowlip2_temloc ac_cn_lowlip_temloc' )
        mc.button('load_lowlid',bgc =(0.4,0.35,0) ,c = lambda *args:self.loadTextField( 'lowlid_temLoc_textField' ) )
        mc.setParent('mouth_temloc_frameLY')
        ##
        mc.rowLayout( 'L_conner_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'L_conner_temLoc  :  ')
        mc.textField( 'L_conner_temLoc_textField',text='ac_lf_cornerlip_temloc' )
        mc.button('load_L_conner' ,bgc =(0.4,0.35,0),c = lambda *args:self.loadTextField( 'L_conner_temLoc_textField' ) )
        mc.setParent('mouth_temloc_frameLY')
        ##
        mc.rowLayout( 'R_conner_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'R_conner_temLoc  :  ')
        mc.textField( 'R_conner_temLoc_textField',text='ac_rt_cornerlip_temloc' )
        mc.button('load_uplid' ,bgc =(0.4,0.35,0),c = lambda *args:self.loadTextField( 'R_conner_temLoc_textField' ) )
        mc.setParent('mouth_temloc_frameLY')
        ##
        mc.rowLayout( 'center_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'center_temLoc  :  ')
        mc.textField( 'center_temLoc_textField',text='ac_cn_mouth_temloc' )
        mc.button('load_center' ,bgc =(0.4,0.35,0),c = lambda *args:self.loadTextField( 'center_temLoc_textField' ) )
        mc.setParent('mouth_temloc_frameLY')
        ##
        mc.rowLayout( 'jaw_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'jaw_temLoc  :  ')
        mc.textField( 'jaw_temLoc_textField',text='ac_cn_jaw_temloc' )
        mc.button('load_jaw' ,bgc =(0.4,0.35,0),c = lambda *args:self.loadTextField( 'jaw_temLoc_textField' ) )
        mc.setParent('mouth_temloc_frameLY')
        
        ##
        mc.rowLayout( 'tongue_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'tongue_temLoc  :  ')
        mc.textField( 'tongue_temLoc_textField',text='ac_cn_tongue1_temloc ac_cn_tongue2_temloc ac_cn_tongue3_temloc ac_cn_tongue4_temloc' )
        mc.button('load_tongue' ,bgc =(0.4,0.35,0),c = lambda *args:self.loadTextField( 'tongue_temLoc_textField' ) )
        mc.setParent('mouth_temloc_frameLY')
        
        ##
        mc.rowLayout( 'tooth_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'tooth_temLoc  :  ')
        mc.textField( 'tooth_temLoc_textField',text='ac_cn_lowerteeth_temloc ac_cn_upperteeth_temloc' )
        mc.button('load_tooth' ,bgc =(0.4,0.35,0),c = lambda *args:self.loadTextField( 'tooth_temLoc_textField' ) )
        mc.setParent('mouth_temloc_frameLY')
        ##
        mc.rowLayout( 'pucker_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'pucker_temLoc  :  ')
        mc.textField( 'pucker_temLoc_textField',text='ac_cn_pucker_temloc' )
        mc.button('load_pucker' ,bgc =(0.4,0.35,0),c = lambda *args:self.loadTextField( 'pucker_temLoc_textField' ) )
        
        
        
        
        
        mc.setParent('mouth_setting_frameLY')
        '''
        =========================================================
        ||                                                     ||
        ||                                                     ||
        ||                                                     ||
        ||                                                     ||
        =========================================================
        
        
        
        '''
        mc.separator( style='in' )
        
        ##
        mc.rowLayout( 'position_note_rowLY',numberOfColumns=1,columnAlign=(1, 'center'))
        mc.text(  '                          the position of secondry joint ',align = 'center' , font = 'boldLabelFont' )

        mc.setParent('mouth_setting_frameLY')
        
        
        #mc.button('load_uplips' ,c = lambda *args:self.loadTextField( 'uplip_influnec_temLoc_textField' ) )
        
        
        ##
        mc.rowLayout( 'uplip_influnec_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'uplip_TemPositin  :  ')
        mc.textField( 'uplip_influnec_temLoc_textField',text='' )
        mc.button('load_uplips' ,bgc=(0.75,0.75,0.3),c = lambda *args:self.loadTextField( 'uplip_influnec_temLoc_textField' ) )
        mc.setParent('mouth_setting_frameLY')
        ##
        mc.rowLayout( 'lowlip_influnec_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'lowlip_TemPositin  :  ')
        mc.textField( 'lowlip_influnec_temLoc_textField',text='' )
        mc.button('load_lowlips' ,bgc=(0.75,0.75,0.3),c = lambda *args:self.loadTextField( 'lowlip_influnec_temLoc_textField' ) )
        mc.setParent('mouth_setting_frameLY')
        ##
        mc.rowLayout( 'conner_influnec_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'conner_TemPositin  :  ')
        mc.textField( 'conner_influnec_temLoc_textField',text='' )
        mc.button('load_conner' ,bgc=(0.75,0.75,0.3),c = lambda *args:self.loadTextField( 'conner_influnec_temLoc_textField' ) )
        mc.setParent('mouth_setting_frameLY')
        
        
        
        mc.radioButtonGrp( 'mouth_mirrorTempleLoc_RBG',label='mirrror :',columnWidth5 = [ 50,5,50,5,50], labelArray2=['L >> R', 'R >> L'], numberOfRadioButtons=2 ,sl = 1 )
        mc.radioButtonGrp( 'mouth_mirrorTempleLoc_RBG',e=True,columnWidth = [1,50]  )
        
        mc.button('mirrorTempleLoc' ,bgc=(0.75,0.75,0.3), c = lambda *args:self.mouth_mirror_temloc() )
        
        #mc.setParent( 'LZ_realistBodySys_main' )
        mc.button('build_mouth_setting',bgc=(0.75,0.75,0.3),c = lambda *args:self.builde_mouth_setting() )
        #mc.button('build_rig_setting',c = lambda *args:self.build_rig_setting() )
        
        
        ##
        mc.rowLayout( 'link_2_head_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'headStretch_jaw  :  ')
        mc.textField( 'link_headStretch_textField',text='' )
        mc.button('load_stretchJaw ' ,bgc=(0.75,0.75,0.3),l='load',c = lambda *args:self.loadTextField( 'link_headStretch_textField' ) )
        mc.setParent('mouth_setting_frameLY')
        
        
        mc.button('link_2_head_setting',bgc=(0.75,0.75,0.3),c = lambda *args:self.linkMouth_2_headStretch() )
        
        mc.button('import_rotateLip_temple',bgc=(0.75,0.75,0.3),c = lambda *args:self.import_rotatelip_temple() )
        mc.button('lip_rotate_update',bgc=(0.75,0.75,0.3),c = lambda *args:self.update_lipRotate_setting() )
        mc.button('update_addLip_roll',bgc=(0.75,0.75,0.3),c = lambda *args:self.update_addLip_roll_def() )
        mc.button('resetMouthSecCtrl',bgc=(0.75,0.75,0.3),c = lambda *args:self.resetMouthCtrlPosition() )
        
        
        '''
        =========================================================
        ||                                                     ||
        ||              nose window                            ||
        ||                                                     ||
        ||                                                     ||
        =========================================================
        
        
        
        '''
        mc.setParent( main )
        mc.frameLayout( 'nose_setting_frameLY',collapse = 1,label='nose_settings', borderStyle='in',collapsable=True,bgc =(0.1,0.1,0.1) ,font = 'boldLabelFont')
        mc.separator( style='none' )

        
        mc.button('  import nose temple   ',h=35,bgc=(0.1,0.9,1), c = lambda *args:self.nose_temple())
        
        mc.frameLayout( 'nose_temloc_frameLY',collapse = 1 ,label='nose_temlocs  (click here if you want to modify)', borderStyle='in',collapsable=True,bgc =(0.1,0.45,0.5) ,font = 'boldLabelFont')
        
        ##
        mc.rowLayout( 'nose_temple_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'nose_temLoc  :  ')
        mc.textField( 'nose_temLoc_textField',text='ac_cn_nose_temloc ac_cn_nosetip_temloc ac_cn_nosebase_temloc ac_lf_nostril_temloc ac_rt_nostril_temloc' )
        mc.button('load_nose' ,bgc =(0.1,0.45,0.5),c = lambda *args:self.loadTextField( 'nose_temLoc_textField' ) )
        
                
        ##
        mc.setParent('nose_temloc_frameLY')

        mc.rowLayout( 'noseRivet_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'noseRivet_temLoc  :  ')
        mc.textField( 'noseRivet_temLoc_textField',text=' ac_cn_nose_rivetloc ac_cn_nosetip_rivetloc ac_cn_nosebase_rivetloc ac_lf_nostril_rivetloc ac_rt_nostril_rivetloc' )
        mc.button('load_noseRivet' ,bgc =(0.1,0.45,0.5),c = lambda *args:self.loadTextField( 'noseRivet_temLoc_textField' ) )
        
        ##
        mc.setParent('nose_temloc_frameLY')
        
        mc.rowLayout( 'nose_skinMesh_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'nose_skinMesh  :  ')
        mc.textField( 'nose_skinMesh_textField',text='' )
        mc.button('nose_skinMesh' ,bgc =(0.1,0.45,0.5),c = lambda *args:self.loadTextField( 'nose_skinMesh_textField' ) )
        
                
        ##
        mc.setParent('nose_temloc_frameLY')

        mc.rowLayout( 'nose_BlendMesh_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'nose_BlendMesh :  ')
        mc.textField( 'nose_BlendMesh_textField',text='' )
        mc.button('nose_BlendMesh' ,bgc =(0.1,0.45,0.5),c = lambda *args:self.loadTextField( 'nose_BlendMesh_textField' ) )
        
        
        
        
        
        ###--------------------------------
        
        mc.setParent('nose_setting_frameLY' )
        mc.separator( style='in' )
        mc.button('  build nose stretch  ',h=30,bgc=(0.1,0.9,1), c = lambda *args:self.createNoseSetting())
        
        
        '''
        =========================================================
        ||                                                     ||
        ||              cheek window                           ||
        ||                                                     ||
        ||                                                     ||
        =========================================================
        
        
        
        '''
        mc.setParent( main )
        mc.frameLayout( 'singgle_setting_frameLY',collapse = 1,label='cheek_settings', borderStyle='in',collapsable=True,bgc =(0.1,0.1,0.1) ,font = 'boldLabelFont')
        mc.separator( style='none' )

        
        
        
        mc.frameLayout( 'singgle_temloc_frameLY',collapse = 1 ,label='nose_temlocs  (click here if you want to modify)', borderStyle='in',collapsable=True,bgc =(0.1,0.45,0.5) ,font = 'boldLabelFont')
        
        ##
        mc.rowLayout( 'singgle_temple_rowLY',numberOfColumns=3,columnWidth3=(100, 150,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  'singgle_temLoc  :  ')
        mc.textField( 'singgle_temLoc_textField',text='ac_lf_squint_temloc ac_lf_cheek_temloc' )
        mc.text('temple list')
        
        mc.setParent( 'singgle_temloc_frameLY' )
        
        ##
        mc.rowLayout( 'ifMirror_temple_rowLY',numberOfColumns=1)

        mc.radioButtonGrp( 'ifMirrorSection' , numberOfRadioButtons=2, label = 'ifMirror  :   ', labelArray2=['no', 'yes'] ,select = 2 )
        
        mc.setParent( 'singgle_temloc_frameLY' )
        
        ##
        mc.rowLayout( 'ifCreateBS_temple_rowLY',numberOfColumns=1)

        mc.radioButtonGrp( 'ifCreateBSSection' , numberOfRadioButtons=2, label = 'ifCreateBS  :   ', labelArray2=['no', 'yes'] ,select = 2 )
        
        mc.setParent( 'singgle_temloc_frameLY' )
        
        ##
        mc.rowLayout( 'ifCreateJnt_temple_rowLY',numberOfColumns=1)

        mc.radioButtonGrp( 'ifCreateJntSection' , numberOfRadioButtons=2, label = 'ifCreateJnt  :   ', labelArray2=['no', 'yes'] ,select = 1 )
        
        
        mc.setParent( 'singgle_temloc_frameLY' )
        ##
        mc.rowLayout( 'axisWork_temple_rowLY',numberOfColumns=1)
        mc.optionMenu( 'axis_work_option',label='                          Axis_work :   ' )
        mc.menuItem( label='  tx & ty  ' )
        mc.menuItem( label='  tx & tz  ' )
        mc.menuItem( label='  ty & tz  ' )
        
        #mc.button('load_cheek' ,bgc =(0.1,0.45,0.5),c = lambda *args:self.loadTextField( 'singgle_temLoc_textField' ) )
        
        mc.setParent('singgle_setting_frameLY' )
        mc.button('  import singgle temple   ',h=35,bgc=(0.1,0.9,1), c = lambda *args:self.createSinggleSetting())
        
        ###--------------------------------
        
        mc.setParent('singgle_setting_frameLY' )
        mc.separator( style='in' )
        mc.button('  build setting  ',h=30,bgc=(0.1,0.9,1), c = lambda *args:self.createSinggle_setting())
        
        mc.showWindow()
    

    '''
    =========================================================
    ||                                                     ||
    ||            singgle                                  ||
    ||                                                     ||
    ||                                                     ||
    =========================================================
    

    
    
    '''    
    def createSinggleSetting(self):
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        IfMirror_value = mc.radioButtonGrp( 'ifMirrorSection' ,q = True, select = True )
        
        singgle_infulence_orglist =self.getTextFieldInfo( 'singgle_temLoc_textField' )
        singgle_sp_tem = self.seperateList( inputValue = singgle_infulence_orglist)
        
        
        if IfMirror_value == 1 :
            mirror_value = 0
        else:
            mirror_value = 1
        
        for sst in singgle_sp_tem:
            
            self.createSinggleTemple(  prefix = pref , section = sst , ifMirror = mirror_value ,  orgPrefix = 'lf_' , mirrorPrefix = 'rt_' )

            if '_cheek_' in sst:
                mc.setAttr(str(sst)+'.translateX' , 6.738 )
                mc.setAttr(str(sst)+'.translateY' , 174.096 )
                mc.setAttr(str(sst)+'.translateZ' , 6.601 )
                
                if  mirror_value == 1:
                    R_sst = str(sst).replace( 'lf_' , 'rt_')
                    
                    mc.setAttr(str(R_sst)+'.translateX' , -6.738 )
                    mc.setAttr(str(R_sst)+'.translateY' , 174.096 )
                    mc.setAttr(str(R_sst)+'.translateZ' , 6.601 )
                
                
            if '_squint_' in sst:
                mc.setAttr(str(sst)+'.translateX' , 4.42 )
                mc.setAttr(str(sst)+'.translateY' , 178.3 )
                mc.setAttr(str(sst)+'.translateZ' , 9.368 )
                
                if  mirror_value == 1:
                    R_sst = str(sst).replace( 'lf_' , 'rt_')
                    
                    mc.setAttr(str(R_sst)+'.translateX' , -4.42 )
                    mc.setAttr(str(R_sst)+'.translateY' , 178.3  )
                    mc.setAttr(str(R_sst)+'.translateZ' , 9.368 )
            
    def createSinggle_setting(self):
    
        donottouchGrp = 'singgle_donottoutch'
        parentHead = 'singgle_parentHead'
        
        if mc.objExists(donottouchGrp) == 0:
            mc.group(em=True , n = donottouchGrp )
            
        if mc.objExists(parentHead) == 0:
            mc.group(em=True , n = parentHead )
    
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        IfMirror_value = mc.radioButtonGrp( 'ifMirrorSection' ,q = True, select = True )
        headMesh_org = mc.textField('head_model_textField',q=True,text =True)
        if_BS = mc.radioButtonGrp( 'ifCreateBSSection' , q=True ,select = True )
        if_jnt = mc.radioButtonGrp( 'ifCreateJntSection' , q=True ,select = True )
        select_value = mc.optionMenu( 'axis_work_option',q=True , select = True )
        
        singgle_infulence_orglist =self.getTextFieldInfo( 'singgle_temLoc_textField' )
        singgle_sp_tem = self.seperateList( inputValue = singgle_infulence_orglist)
        
        
        
        headMesh = str(headMesh_org)+'_bridgeMesh'
        
        if mc.objExists(headMesh) == False:
            mc.duplicate(headMesh_org , n = headMesh )
            blendNode = str( headMesh_org ) + '_blendNode'
            
            mc.blendShape( headMesh , headMesh_org ,n =blendNode )
            mc.setAttr( str(blendNode) + '.' + str(headMesh) , 1 )
            
        
        if select_value == 1:
            attrUse = ['tx','ty']
        elif  select_value == 2:
            attrUse = ['tx','tz']
        elif  select_value == 3:
            attrUse = ['ty','tz']
        
        
        if IfMirror_value == 1 :
            mirror_value = 0
        else:
            mirror_value = 1
            
        if if_BS == 1 :
            bs_value = 0
        else:
            bs_value = 1
            
        if if_jnt == 1 :
            jnt_value = 0
        else:
            jnt_value = 1
            
            
        
        for sstm in singgle_sp_tem:
            sst = pref + str(sstm)
            if '_squint_' in sst:
                jnt_value = 1
                bs_value = 0
            elif '_cheek_' in sst:
                
                jnt_value = 0
                bs_value = 1
                

            position_tem = mc.xform(sst , q=True, t=True,ws=True)
            ctrlName = str(sst).replace('_temloc', '_ctrl')
            zeroCtrl = self.create_secondry_grp( ctrl_name = ctrlName ,position = position_tem,IfInverse = 0)
            
            mc.parent(zeroCtrl , parentHead )
            self.creatControls_command( type = 14 ,curName= ctrlName ,add=True)
            
            for  attr in [ 'rx','ry','rz','sx','sy','sz','v' ]:
                mc.setAttr( str(ctrlName) +'.'+ str(attr) , k = False ,l=True )
                
                
                if bs_value == 1 :
                    mc.setAttr( str(ctrlName) +'.tz'  , k = False ,l=True )
                    mc.transformLimits( ctrlName ,tx=(-1, 1), ty=(-1, 1), etx=(True, True), ety=(True, True) )
            
            self.createSinggle_SDK_blendshape( inputMesh = headMesh , ifCreateBS = bs_value , ifCC_jnt = jnt_value , ctrl = ctrlName , attr_use = attrUse ,reverse_Z = 0)
            
            
            if mirror_value == 1:
                R_ctrl = str(ctrlName).replace('_lf','_rt')
                zeroCtrl =self.create_secondry_grp( ctrl_name = R_ctrl ,position = ( position_tem[0]*-1 ,position_tem[1],position_tem[2]),IfInverse = 1 )
                mc.parent(zeroCtrl , parentHead )
                self.creatControls_command( type = 14 ,curName= R_ctrl ,add=True)
                
                for  attr in [ 'rx','ry','rz','sx','sy','sz','v' ]:
                    mc.setAttr( str(R_ctrl) +'.'+ str(attr) , k = False ,l = True )
                    
                    if bs_value == 1 :
                        mc.setAttr( str(R_ctrl) +'.tz'  , k = False ,l=True )
                        mc.transformLimits( R_ctrl ,tx=(-1, 1), ty=(-1, 1), etx=(True, True), ety=(True, True) )
                
                
                self.createSinggle_SDK_blendshape( inputMesh = headMesh , ifCreateBS = bs_value , ifCC_jnt = jnt_value , ctrl = R_ctrl , attr_use = attrUse ,reverse_Z = 1 )
                
        
    def createSinggle_SDK_blendshape(self , inputMesh = '' , ifCreateBS = 1 , ifCC_jnt = 1 , ctrl = 'xxx_bbb01_ctrl' , attr_use = ['tx','ty'] ,reverse_Z = 1 ):
        
        
        
        donottouchGrp = 'singgle_donottoutch'
        parentHead = 'singgle_parentHead'
        
        if mc.objExists(donottouchGrp) == 0:
            mc.group(em=True , n = donottouchGrp )
            
        if mc.objExists(parentHead) == 0:
            mc.group(em=True , n = parentHead )
        
        if ifCreateBS == 1:
            bridge = self.plane_8dir_sdk( driver = ctrl ,firstAttr = attr_use[0] ,secondryAttr = attr_use[1],dircNormalValue = [1,1,1,1] )
            bridgeAttrs = [ 'up_driver' ,'out_driver','dn_driver','inn_driver','upOut_driver','upInn_driver','dnOut_driver','dnInn_driver']
            mc.parent( bridge , donottouchGrp )
            
            Mesh_bs = str(inputMesh) + '_singgleMesh'
            grp_mesh = str(inputMesh) + '_singgleMesh'+'_blendshape'
            
            if mc.objExists(grp_mesh) == 0 :
                mc.group(em= True,n = grp_mesh )
            
            if mc.objExists(Mesh_bs) == False:
                mc.duplicate( inputMesh , n = Mesh_bs )
                mc.parent( Mesh_bs , donottouchGrp )
            for bda  in  bridgeAttrs:
                target_bs = str(ctrl)+'_'+str(bda)
                blend_node = str(Mesh_bs) + '_blendNode'
                if mc.objExists(target_bs) == False:
                    mc.duplicate( inputMesh , n = target_bs )
                    mc.parent( target_bs , grp_mesh )
                self.AppendTarget(  targets = [target_bs] , BlendMesh = Mesh_bs, blendshape_node = blend_node )
                
                driver = str(bridge) + '.' + str( bda )
                driven = str(blend_node) + '.' + str( target_bs )
                self.LZ_serDrivenKey_02( driverAttr = driver , drivenAttr = driven  ,driverV = [0,1] , drivenV = [ 0 , 1 ] ,inType = 'linear' ,outType = 'linear' , preV = 'cycleRelative', poiV = 'cycleRelative')
        if ifCC_jnt ==1:
            jntName = str(ctrl)+'_jnt'
            position = mc.xform(ctrl , q=True,t=True,ws =True)
            rotation_V = mc.xform(ctrl , q=True,ro=True,ws =True)
            
            self.createTransformer( locName = jntName ,position = position ,rotation = rotation_V, type = 'joint',LocPosion = (0,0,0))
            
            mc.parent( jntName , donottouchGrp )
            self.makeZeroGrpTwo( OrgObj = [jntName],sufname='_zero',cenObj='',Mode=0,type = 'group',ro =True)
            mc.connectAttr(str(ctrl)+'.translateX' , str(jntName)+'.translateX')
            mc.connectAttr(str(ctrl)+'.translateY' , str(jntName)+'.translateY')
            #mc.connectAttr(str(ctrl)+'.translateZ' , str(jntName)+'.translateZ')
            
            mc.connectAttr(str(ctrl)+'.rotateX' , str(jntName)+'.rotateX')
            mc.connectAttr(str(ctrl)+'.rotateY' , str(jntName)+'.rotateY')
            mc.connectAttr(str(ctrl)+'.rotateZ' , str(jntName)+'.rotateZ')
            
            if reverse_Z == 0 :
                mc.connectAttr(str(ctrl)+'.translateZ' , str(jntName)+'.translateZ')
                
            else:
                reverseNode = str(jntName)+'_reverse_md'
                mc.createNode('multiplyDivide' , n = reverseNode )

                mc.connectAttr(str(ctrl)+'.translateZ' , str(reverseNode)+'.input1Z')
                
                mc.setAttr(str(reverseNode)+'.input2Z' , -1)
                
                mc.connectAttr(  str(reverseNode)+'.outputZ' , str(jntName)+'.translateZ')
             
            
    '''
    =========================================================
    ||                                                     ||
    ||             mouth                                   ||
    ||                                                     ||
    ||                                                     ||
    =========================================================
    
    
    
    '''    
    def createTemploc_forUI(self):
    
        #prefix = mc.textField( 'charator_prefix_textField',q=True,text=True )
        
        self.create_mouthDefaultTemple()
        
        upLid = ['uplid_temLoc_textField','ac_lf_uplip1_temloc ac_lf_uplip2_temloc ac_rt_uplip1_temloc ac_rt_uplip2_temloc ac_cn_uplip_temloc']
        lowLid = ['lowlid_temLoc_textField','ac_lf_lowlip1_temloc ac_rt_lowlip1_temloc ac_lf_lowlip2_temloc ac_rt_lowlip2_temloc ac_cn_lowlip_temloc']
        L_conner = ['L_conner_temLoc_textField','ac_lf_cornerlip_temloc']
        R_conner = ['R_conner_temLoc_textField','ac_rt_cornerlip_temloc']
        center= ['center_temLoc_textField','ac_cn_mouth_temloc']
        jaw = ['jaw_temLoc_textField','ac_cn_jaw_temloc']
        
        
        pucker = ['pucker_temLoc_textField','ac_cn_pucker_temloc']
        tongue = ['tongue_temLoc_textField','ac_cn_tongue1_temloc ac_cn_tongue2_temloc ac_cn_tongue3_temloc ac_cn_tongue4_temloc']
        tooth = ['tooth_temLoc_textField','ac_cn_lowerteeth_temloc ac_cn_upperteeth_temloc']
        
        for i in [upLid,lowLid,L_conner,R_conner,center,jaw,pucker,tongue,tooth]:
            mc.textField( i[0],e=True,text=i[1]   )
    
    def mouth_mirror_temloc(self):
    
        
        textFields = [ 'uplid_temLoc_textField' , 'lowlid_temLoc_textField']
        conner_textFields = [ 'L_conner_temLoc_textField','R_conner_temLoc_textField']
        currentSl = mc.radioButtonGrp( 'mouth_mirrorTempleLoc_RBG',q=True,select = True )
        
        for tf in textFields:
            info_lips = self.getTextFieldInfo(tf)
            mount = len(info_lips)
            info = self.find_max2Min_list(info_lips)
            centerLocInfo = info[(mount-1)/2]
            
            for io_num in range(mount) :
                if currentSl == 1:
                    if info[io_num][1][0] > centerLocInfo[1][0]:
                        
                        mc.xform( info[mount-io_num-1][0] , t = (centerLocInfo[1][0]*2- info[io_num][1][0], info[io_num][1][1],info[io_num][1][2] ),ws=True   )
                        #
                        #
                        #mc.setAttr(str(info[mount-io_num-1][0])+'.translateX',info[io_num][1][0]*-1)
                        #mc.setAttr(str(info[mount-io_num-1][0])+'.translateY',info[io_num][1][1]*1)
                        #mc.setAttr(str(info[mount-io_num-1][0])+'.translateZ',info[io_num][1][2]*1)
                else:
                    if info[io_num][1][0] < centerLocInfo[1][0]:
                        mc.xform( info[mount-io_num-1][0] , t = (centerLocInfo[1][0]*2- info[io_num][1][0], info[io_num][1][1],info[io_num][1][2] ) ,ws=True   )
                        #mc.setAttr(str(info[mount-io_num-1][0])+'.translateX',info[io_num][1][0]*-1)
                        #mc.setAttr(str(info[mount-io_num-1][0])+'.translateY',info[io_num][1][1]*1)
                        #mc.setAttr(str(info[mount-io_num-1][0])+'.translateZ',info[io_num][1][2]*1)
        
        L_conner = self.getTextFieldInfo(conner_textFields[0])
        R_conner = self.getTextFieldInfo(conner_textFields[1])
        
        info_Lconner = self.find_max2Min_list(L_conner)
        info_Rconner = self.find_max2Min_list(R_conner)

        
        if  currentSl == 1:
        
            mc.xform( R_conner[0], t = (centerLocInfo[1][0]*2- info_Lconner[0][1][0], info_Lconner[0][1][1],info_Lconner[0][1][2] ),ws=True   )
            #mc.setAttr( str(R_conner[0])+'.translateX' ,info_Lconner[0][1][0] *-1 )
            #mc.setAttr( str(R_conner[0])+'.translateY' ,info_Lconner[0][1][1]  )
            #mc.setAttr( str(R_conner[0])+'.translateZ' ,info_Lconner[0][1][2]  )
            
        else:
            mc.xform( L_conner[0], t = (centerLocInfo[1][0]*2- info_Rconner[0][1][0], info_Rconner[0][1][1],info_Rconner[0][1][2] ),ws=True   )
            #mc.setAttr( str(L_conner[0])+'.translateX' ,info_Rconner[0][1][0] *-1 )
            #mc.setAttr( str(L_conner[0])+'.translateY' ,info_Rconner[0][1][1]  )
            #mc.setAttr( str(L_conner[0])+'.translateZ' ,info_Rconner[0][1][2]  )
    
            

    def builde_mouth_setting(self):
    
        headMesh_org = mc.textField('head_model_textField',q=True,text =True)
        
        headMesh = str(headMesh_org)+'_bridgeMesh'
        
        if mc.objExists(headMesh) == False:
            mc.duplicate(headMesh_org , n = headMesh )
            blendNode = str( headMesh_org ) + '_blendNode'
            
            mc.blendShape( headMesh , headMesh_org ,n =blendNode )
            mc.setAttr( str(blendNode) + '.' + str(headMesh) , 1 )
    
        upLid = 'uplid_temLoc_textField'
        lowLid = 'lowlid_temLoc_textField'
        L_con = 'L_conner_temLoc_textField'
        R_con = 'R_conner_temLoc_textField'
        fillCon  = []
        
        centerLoc = mc.textField( 'center_temLoc_textField',q=True,text = True )
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        
        
        mouth_scuplt_split = str(centerLoc).split('_')
        mouth_scuplt_grp = str(centerLoc).replace(mouth_scuplt_split[-1],'scuplt_grp')
        mouth_ctrl_grp = str(centerLoc).replace(mouth_scuplt_split[-1],'ctrl_grp')
        mouth_secjnt_grp = str(centerLoc).replace(mouth_scuplt_split[-1],'secjnt_grp')
        
        if mc.objExists(mouth_scuplt_grp) == 0:
            mc.group(em = True,n = mouth_scuplt_grp)
        else:
            pass
        
        for i in [upLid,lowLid,L_con,R_con]:
            textFill = mc.textField( i,q=True,text= 1  )
            part_all=[]
            for part in textFill.split(' '):
                if part !='':
                    part_all.append(part)
            fillCon.append(part_all)

        curves = 'mouth_' + pref +  'lip_deformer'
        uplip_conName = 'ac_cn_' + pref + 'upperlip_con'
        lowlip_conName = 'ac_cn_' + pref + 'lowerlip_con'
        alllip_conName = 'ac_cn_' + pref + 'lip_con'
        offsetGrp = pref +  'ac_cn_jaw_offset'
        
        jaw_tem = mc.textField( 'jaw_temLoc_textField' ,q=True,text=True)
        jaw_jnt = str(jaw_tem).replace('_temloc' , '_jnt')
        
        curveName = self.builde_nurbs(nurbsName = curves , upperLids = fillCon[0] ,lowerLis = fillCon[1],L_conner = fillCon[2][0] ,R_conner = fillCon[3][0] , center = centerLoc ,jaw = jaw_tem ,uplip_con = uplip_conName ,lowlip_con = lowlip_conName ,all_lip_con = alllip_conName ,zerogrp = mouth_ctrl_grp,grp_offset = offsetGrp ,prefix = pref )
        ######################################
        #=====================================
        ##   ---       create secdry joints   ---
        
        uplips_influence_TF = 'uplip_influnec_temLoc_textField'
        lowlips_influence_TF = 'lowlip_influnec_temLoc_textField'
        conner_influence_TF = 'conner_influnec_temLoc_textField'
        influence_all_TF = [uplips_influence_TF,lowlips_influence_TF,conner_influence_TF]
        
        
        influence_uplip = []
        influence_lowlip = []
        influence_conner = []
        influence_all = [influence_uplip,influence_lowlip,influence_conner]
        
        
        
        #self.rivetSecJnt( rivetObjects = uplip_infulence , rivetMesh = curveName ,prefix = 'uplip_mouth_lips') # LZ_general_cammand
        #self.rivetSecJnt( rivetObjects = lowlip_infulence, rivetMesh = curveName ,prefix = 'lowlip_mouth_lips') # LZ_general_cammand
        #self.rivetSecJnt( rivetObjects = center_infulence, rivetMesh = curveName ,prefix = 'center_mouth_lips') # LZ_general_cammand
         
        #----  get information of lips  by textFields  -----
        uplip_infulence_orglist =self.getTextFieldInfo( uplips_influence_TF )
        lowlip_infulence_orglist =self.getTextFieldInfo( lowlips_influence_TF )
        center_infulence_orglist =self.getTextFieldInfo( conner_influence_TF )
        
        uplip_infulence = self.seperateList( inputValue = uplip_infulence_orglist)
        lowlip_infulence = self.seperateList( inputValue = lowlip_infulence_orglist)
        center_infulence = self.seperateList( inputValue = center_infulence_orglist)
        

        
        secjnt_uppref =  pref +  'uplips'
        secjnt_lowpref =  pref +  'lowlips'
        secjnt_connerpref =  pref +  'connerlips'
        
        ###   ==================================================================================================
        parentHead_grp = pref+'mouth_parentHead'
        donottoutch_grp = pref+'mouth_donottouch'
        
        if mc.objExists(parentHead_grp)==0:
            mc.group(em=True ,n = parentHead_grp )
        if mc.objExists(donottoutch_grp)==0:
            mc.group(em=True ,n = donottoutch_grp )
        
        #----  excute the def crateSEcJnt  -----
        
        puckerTem = mc.textField( 'pucker_temLoc_textField' ,q=True,text=True)
        tongueTem = mc.textField( 'tongue_temLoc_textField' ,q=True,text=True)
        tongue_infulence_orglist =self.getTextFieldInfo( 'tongue_temLoc_textField' )
        tongue_sp_tem = self.seperateList( inputValue = tongue_infulence_orglist)
        
        tooth_infulence_orglist =self.getTextFieldInfo( 'tooth_temLoc_textField' )
        tooth_sp_tem = self.seperateList( inputValue = tooth_infulence_orglist)
        
        info_secjnt = self.createSecJnt( tooth = tooth_sp_tem , tongue = tongue_sp_tem  , uplips = uplip_infulence ,pucker = puckerTem ,uplipPrifix = secjnt_uppref,lowlips =lowlip_infulence, lowlipPrifix = secjnt_lowpref ,connerlips =center_infulence ,connerPrefix = secjnt_connerpref ,rivetMesh = curveName[0] ,prefix = pref ,sufix = '_secjnt',grp_all= mouth_secjnt_grp ,grp_offset = offsetGrp , followHead =curveName[7],followJaw = curveName[6],mouthZipperAttr = [curveName[8]+'.lf_lip_zipper',curveName[8]+'.rt_lip_zipper'] )
        
        for openjnt_info in info_secjnt[5]:
            openjnt = openjnt_info[0]
            
            ifskin = self.IfSkined(  inputMesh = headMesh_org ) 


            if ifskin == 0:
                mc.skinCluster( openjnt , headMesh_org ,toSelectedBones =True ,normalizeWeights = 1 )
            else:
                skinNode_headgeo = self.listSkinCluster(inputMesh = headMesh_org)
            
                jntInf = self.listAllSkined_joints( skinClus = skinNode_headgeo )
            
                
                if openjnt not in  jntInf :
                    #print(skinNode_headgeo)
                    
                    mc.skinCluster( skinNode_headgeo , e=True ,ai = openjnt ,lw =True, wt = 0 )
                    
        mc.skinCluster( skinNode_headgeo ,e=True, ai = jaw_jnt   )
        uplip_jnts = []
        lowlip_jnts = []
        connerlip_jnts = []
        
        #uplips_obj = []
        #lowlips_obj = []
        #connerlips_obj = []
        # ---------------------  make orientConstraints for mouth secondry joints  ----------------- 
        for uplip in info_secjnt[0]:
            #uplips_obj.append(uplip[0])
            congrp = str(uplip[0])+'_con'
            mc.orientConstraint( curveName[1] , congrp ,mo=True) 
            #mc.connectAttr(str(curveName[1])+'.rotate',str(uplip[0])+'.rotate')
            uplip_jnts.append(uplip[0])
            
        for lowlip in info_secjnt[1]:
            #lowlips_obj.append(lowlip[0])
            congrp = str(lowlip[0])+'_con'
            mc.orientConstraint( curveName[2] , congrp ,mo=True) 
            
            #mc.connectAttr(str(curveName[2])+'.rotate',str(lowlip[0])+'.rotate')
            lowlip_jnts.append(lowlip[0])
            
        for connerlip in info_secjnt[2]:
            #connerlips_obj.append(connerlip[0])
            congrp = str(connerlip[0])+'_con'
            mc.orientConstraint( curveName[1] ,curveName[2] , congrp ,mo=True) 
            #mc.connectAttr(str(curveName[3])+'.rotate',str(connerlip[0])+'.rotate')
            connerlip_jnts.append(connerlip[0])
            
        mc.parent( curveName[4] , info_secjnt[3] , mouth_scuplt_grp )
        
        if mc.listRelatives(mouth_scuplt_grp,p=True) == None:
            mc.parent( mouth_scuplt_grp , donottoutch_grp)
        
        ######################################
        #=====================================
        ##   ---       skinCluster secondryJnts   ---
        
        
        
        self.addskinClusters_models( modelHead = headMesh ,jnts = uplip_jnts+ lowlip_jnts + connerlip_jnts ,pref = pref ,sufix = '_Scuplt_mesh')
        
        ######################################
        #=====================================
        ##   ---       createBlendshape   ---
        self.buildBaseBlendShape( headModel = headMesh , prefix = pref ,sufix = '_mouthScuplt_mesh' )
        
        ######################################
        #=====================================
        ##   ---       createBlendshape   ---
        
        
        connerCtrl = [pref+'ac_lf_mouth_ctrl',pref+'ac_rt_mouth_ctrl']
        #L_con = 'L_conner_temLoc_textField'
        #R_con = 'R_conner_temLoc_textField'
        
        
        ######################################
        #=====================================
        ##  -------create mouth conner
        temLoc_conner_L = mc.textField(L_con,q=True,text = True)
        temLoc_conner_R = mc.textField(R_con,q=True,text = True)
        bridgeGrp_mouth = pref+'mouth_bridge_grp'
        
        L_position = mc.xform(temLoc_conner_L,q=True,t=True,ws=True)
        R_position = mc.xform(temLoc_conner_R,q=True,t=True,ws=True)
        
        mouthConnerCtrl = [ (connerCtrl[0],L_position) , (connerCtrl[1],R_position) ] 
        
        self.mouthConner_setting( connerCtrlInfo = mouthConnerCtrl ,prefix = pref )
        
        self.setDrivenKey_forMouthBlendshape(ctrls=connerCtrl , pref = pref , bridgeGrp = bridgeGrp_mouth , poutCtrl = info_secjnt[4]  )
    
    
    
    def linkMouth_2_headStretch(self):
        
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        
        puckerTem = mc.textField( 'pucker_temLoc_textField' ,q=True,text=True)
        
        jaw_head_stretch = mc.textField( 'link_headStretch_textField',q=True , text=True )
        
        if puckerTem == ' ':
            puckerObj = puckerTem
        else:
            puckerObj = pref + 'ac_cn_pucker_temloc'
        
        splineName = pref+'ac_cn_midheadlowstretch'
        #jawStretch = splineName + '_LZIkSpline_seketon1_jnt'  

        mouth_bridge = pref +   'mouth_bridge_grp'
        
        jaw_loc = pref + 'ac_cn_jaw_temloc'
        
        headStretchBridge = pref + 'ac_cn_midhead_bridge'
        
        self.link_Mouth_2_headStretch( inputReferenceObj = puckerTem , prefix = pref , jaw_stretch = jaw_head_stretch , bridge = mouth_bridge , jawTemloc = jaw_loc , headStretchBridge =  headStretchBridge )
        
        
        mouthParentStretch = pref + 'mouth_paretStretch'
        mc.parent( mouthParentStretch , jaw_head_stretch )
    
    
    def import_rotatelip_temple(self):
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        self.update_addmouthRotate_temple(  prefix =  pref )
    
    def update_lipRotate_setting(self):
        
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        headMesh_org = mc.textField('head_model_textField',q=True,text =True)
        
        self.update_addmouthRotate_setting( prefix =  pref , orgMesh = headMesh_org )
    
    
    def update_addLip_roll_def(self):
        
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        headMesh_org = mc.textField( 'head_model_textField',q=True , text=True )
        
        headMesh = str(headMesh_org)+'_bridgeMesh'
        
        self.update_addlip_roll(  prefix = pref , bridgemesh = headMesh )
    
    '''
    =========================================================
    ||                                                     ||
    ||             headStretch                             ||
    ||                                                     ||
    ||                                                     ||
    =========================================================
    
    
    
    ''' 
    
    def importStretch_temple(self):
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        
        temple = self.createTemple_stretchHead( prefix = pref )
        

        if len(temple) == 4 :
            upper= temple[0][0]+''+temple[1][0]
            lower= temple[2][0]+''+temple[3][0]
            mc.textField( 'headStretch_up_temLoc_textField',e=True,text=upper )
            mc.textField( 'headStretch_low_temLoc_textField',e=True , text=lower )
        else:
            mc.frameLayout( 'headStretch_temloc_frameLY',e=True,collapse = 0 )
            mc.textField( 'headStretch_up_temLoc_textField',e=True,bgc = (1,0,0) )
            mc.textField( 'headStretch_up_temLoc_textField',e=True,bgc = (1,0,0) )
    
    def buildHeadStretch_setting(self):
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        upJntbase = pref+'ac_cn_midhead_temple'
        upJnttip = pref+'ac_cn_upperhead_temple'
        
        lowJntbase = pref+'ac_cn_midheadlow_temple'
        lowJnttip = pref+'ac_cn_lowerhead_temple'
        
        self.createHesdStretch( upper = [upJntbase,upJnttip] ,lower = [ lowJntbase , lowJnttip ] )
    '''
    =========================================================
    ||                                                     ||
    ||             eyeBrow                                 ||
    ||                                                     ||
    ||                                                     ||
    =========================================================
    
    
    
    ''' 
    def importEyeBrow_temloc(self):
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        all_locs = self.createTemple( prefix = pref )
        textinput = ''
        for num in range(len(all_locs[1])):
            if num ==0:
                textinput = all_locs[1][num]
                
            else:
                textinput = textinput+ ' '+all_locs[1][num]

        mc.textField( 'eyeBrow_temLoc_textField',e=True , text= textinput )
        
        mc.textField( 'eyeBrow_center_temLoc_textField',e=True, text=all_locs[0])
        
        mc.textField( 'curveReference_textField',e=True, text=all_locs[2])
        
    def mirror_eyeBrow_temloc(self):
        
        textInput = mc.textField( 'eyeBrow_temLoc_textField',q=True,text=True )
        center = mc.textField( 'eyeBrow_center_temLoc_textField',q=True, text=True )
        allInputs = str(textInput).split(' ')
        for ai in allInputs:
            if '' == ai:
                allInputs.remove(ai)

        self.eyeBrow_mirror_temloc( centerLoc = center , TemLocs = allInputs , mirrorDir = 1 )
    
    def build_eyeBrow_setting(self):
        headMesh_org = mc.textField( 'head_model_textField',q=True , text=True )
        
        headMesh = str(headMesh_org)+'_bridgeMesh'
        
        if mc.objExists(headMesh) == False:
            mc.duplicate(headMesh_org , n = headMesh )
            blendNode = str( headMesh_org ) + '_blendNode'
            
            mc.blendShape( headMesh , headMesh_org ,n =blendNode )
            mc.setAttr( str(blendNode) + '.' + str(headMesh) , 1 )
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        
        curve_reference = mc.textField( 'curveReference_textField' , q=True,text =True )
        
        
        eyeBrowMesh = pref+'eyeBrow_sculpts_mesh'
        mc.duplicate( headMesh , n=eyeBrowMesh)
        inputs = mc.listHistory(headMesh)
        
        blend_node_name = headMesh +'_blendNode'
        
        self.AppendTarget( targets = [eyeBrowMesh] , BlendMesh = headMesh ,blendshape_node = blend_node_name )
        mc.setAttr(str(blend_node_name)+'.' + str(eyeBrowMesh) , 1 )
        
        self.create_eyeBrow_setting( blendMesh = headMesh , inputMesh = eyeBrowMesh ,prefix = pref , temCurve = curve_reference )
    
    def importCenterLoc(self):
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        self.import_rotateCenter_locator(  prefix = pref )
    
    def update_addRotate(self):
    
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        

        ctrl = pref + 'ac_rt_eyebrow_ctrl'
            
        follow_grp = str(ctrl).replace('_ctrl','_follow_rotation')
        
        if mc.objExists(follow_grp) == 0:

            self.update_for_rotationOneyeBrown(  prefix = pref , dirction = 'left', ifinverse = 0 )
            self.update_for_rotationOneyeBrown(  prefix = pref , dirction = 'right' , ifinverse = 1)

        self.update_eyebrown_rotate_offsetPosition( prefix = pref , dirction = 'left')
        self.update_eyebrown_rotate_offsetPosition( prefix = pref , dirction = 'right')
    
    
    
    
    '''
    =========================================================
    ||                                                     ||
    ||             nose                                    ||
    ||                                                     ||
    ||                                                     ||
    =========================================================

    '''  
    
    def nose_temple(self):
    
        headMesh_org = mc.textField('head_model_textField',q=True,text =True)
        
        headMesh = str(headMesh_org)+'_bridgeMesh'
        
        if mc.objExists(headMesh) == False:
            mc.duplicate(headMesh_org , n = headMesh )
            blendNode = str( headMesh_org ) + '_blendNode'
            
            mc.blendShape( headMesh , headMesh_org ,n =blendNode )
            mc.setAttr( str(blendNode) + '.' + str(headMesh) , 1 )
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        noseTemples = [pref + 'ac_cn_nose_temloc',
                       pref + 'ac_cn_nosetip_temloc', 
                       pref + 'ac_cn_nosebase_temloc', 
                       pref + 'ac_lf_nostril_temloc', 
                       pref + 'ac_rt_nostril_temloc'
        
                       ]
                        
        noseRivetTemples = [pref + 'ac_cn_nose_rivetloc',
                            pref + 'ac_cn_nosetip_rivetloc',
                            pref + 'ac_cn_nosebase_rivetloc',
                            pref + 'ac_lf_nostril_rivetloc',
                            pref + 'ac_rt_nostril_rivetloc'
                            
                            ]
        noseTems = ''
        for nt in noseTemples:
            noseTems = noseTems + ' ' + nt
        noseRivet = ''
        for nr in noseRivetTemples:
            noseRivet = noseRivet +' '+ nr
        self.createNose_temple(  prefix = pref)
        
        
        mc.textField( 'nose_temLoc_textField',e=True , text= noseTems )
        mc.textField( 'noseRivet_temLoc_textField',e=True , text= noseRivet )
        
        
        skinMesh = pref + 'mouth_Scuplt_mesh'
        
        mc.textField( 'nose_skinMesh_textField',e=True , text= skinMesh )
        mc.textField( 'nose_BlendMesh_textField',e=True , text= headMesh )
    def createNoseSetting(self):
        
        
        
        noseInput = mc.textField( 'nose_temLoc_textField',q=True , text= True )
        skinMesh = mc.textField( 'nose_skinMesh_textField',q=True , text= True )
        blendMesh = mc.textField( 'nose_BlendMesh_textField',q=True , text= True )
        
        
        allInputs = str(noseInput).split(' ')
        for ai in allInputs:
            if '' == ai:
                allInputs.remove(ai)
                
        noseRivetInput = mc.textField( 'noseRivet_temLoc_textField',q=True , text= True )
        RivetInputs = str(noseRivetInput).split(' ')
        for ai in RivetInputs:
            if '' == ai:
                RivetInputs.remove(ai)

        self.create_nose_setting( noseTemple = allInputs , noseRivet = RivetInputs,skinMesh = skinMesh ,blendshapeMesh = blendMesh)
    
    '''
    =========================================================
    ||                                                     ||
    ||             eye                                     ||
    ||                                                     ||
    ||                                                     ||
    =========================================================

    '''  
    
    def createEyeAimCtrl(self):
    
        org_pre = mc.textField( 'eye_Org_text_textField',q=True , text = True )
        tar_pre = mc.textField( 'eye_replace_textField' , q=True , text = True )
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        lfEye = mc.textField( 'eye_conter_textField',q=True ,text=True )
        value = mc.floatField( 'eye_aimValue_floatField', q=True , value = True )
        
        rtEye = str(lfEye).replace( org_pre , tar_pre )
        print(lfEye)
        self.create_aimsetting( prefix = pref , lfEyeTem = lfEye ,rtEyeTem = rtEye ,if_lf = 1 , if_rt = 1  , valueAim = value )
    
        #self.create_aimsetting( prefix = '' , lfEyeTem = 'ac_lf_eye_temloc' ,rtEyeTem = 'ac_rt_eye_temloc' ,if_lf = 1 , if_rt = 1 )

    
    def createTemple_eye(self):
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        #IfMirror = mc.checkBox( 'eye_mirror',q = True , value =True  )

        
        info_eyeTemple = self.createEyeTemple( prefix = pref ,ifMirror = 1 )
        

        if info_eyeTemple[0]!= []:
            for socket_num in range(len(info_eyeTemple[0])):
                if socket_num==0:
                    socket_tem = info_eyeTemple[0][0]
                else:
                    socket_tem = socket_tem + ' '+ info_eyeTemple[0][socket_num]
            mc.textField( 'eye_socket_temLoc_textField',e=True,text = socket_tem )
            
            inn_conner = info_eyeTemple[1][0]
            mc.textField( 'inn_eye_conner_textField',e=True,text = inn_conner )
            
            out_conner = info_eyeTemple[1][4]
            mc.textField( 'out_eye_conner_textField',e=True,text = out_conner )
            
            for etupper_num in range(len(info_eyeTemple[1][1:4])):
                if etupper_num==0:
                    upperlid_tem = info_eyeTemple[1][1]
                else:
                    upperlid_tem = upperlid_tem + ' '+ info_eyeTemple[1][etupper_num + 1]
                    
            mc.textField( 'eye_upperlid_temLoc_textField',e=True,text = upperlid_tem )
            
            lowrlid_temple = info_eyeTemple[1][5:8][::-1]
            
            for etlower_num in range(len(lowrlid_temple)):
                
                if etlower_num==0:
                    loerlid_tem = lowrlid_temple[0]
                else:
                    loerlid_tem = loerlid_tem + ' '+ lowrlid_temple[etlower_num ]
                    
            mc.textField( 'eye_lowerlid_textField',e=True,text = loerlid_tem )
            mc.textField( 'eye_conter_textField',e=True,text = info_eyeTemple[2] )
            
            mc.textField( 'eye_eyecrunch_textField',e=True,text=info_eyeTemple[3] )
        
        #upperlid_conner = info_eyeTemple[1][1:4]
        #mc.textField( 'eye_upperlid_temLoc_textField',e=True,text = inn_conner )
        #
        #lowerlid_conner = info_eyeTemple[1][4:8]
        #print(lowerlid_conner)
        #mc.textField( 'eye_lowerlid_textField',e=True,text = lowerlid_conner )
    
    def mdlar_eye_mirror(self):
        
        ['ac_lf_innerlid_temloc','ac_lf_upperlid1_temloc','ac_lf_upperlid2_temloc','ac_lf_upperlid3_temloc','ac_lf_outerlid_temloc','ac_lf_lowerlid3_temloc','ac_lf_lowerlid2_temloc',
            'ac_lf_lowerlid1_temloc','ac_lf_eyecrunch_temloc','ac_lf_innersocket_temloc','ac_lf_uppersocket1_temloc','ac_lf_uppersocket2_temloc','ac_lf_uppersocket3_temloc','ac_lf_outersocket_temloc','ac_lf_lowersocket3_temloc',
            'ac_lf_lowersocket2_temloc','ac_lf_lowersocket1_temloc','ac_lf_eye_temloc']
            
        org_pre = mc.textField( 'eye_Org_text_textField',q=True , text = True )
        tar_pre = mc.textField( 'eye_replace_textField' , q=True , text = True )
        
        mirror_section = mc.radioButtonGrp( 'eye_mirrorTempleLoc_RBG',q=True, sl =True )
        
        socket = mc.textField( 'eye_socket_temLoc_textField', q=True , text = True )
        upperlid = mc.textField( 'eye_upperlid_temLoc_textField', q=True , text = True )
        lowerlid = mc.textField( 'eye_lowerlid_textField', q=True , text = True )
        inn_conner = mc.textField( 'inn_eye_conner_textField', q=True , text = True  )
        outconner = mc.textField( 'out_eye_conner_textField', q=True , text = True  )
        eyeBallcentoer = mc.textField( 'eye_conter_textField', q=True , text = True )
        crunch = mc.textField( 'eye_eyecrunch_textField', q=True , text = True )
        
        eye_socket_all = str(socket).split(' ')
        for ai in eye_socket_all:
            if '' == ai:
                eye_socket_all.remove(ai)
                
        upperlid_all = str(upperlid).split(' ')
        for ai in upperlid_all:
            if '' == ai:
                upperlid_all.remove(ai)
                
        lowerlid_all = str(lowerlid).split(' ')
        for ai in lowerlid_all:
            if '' == ai:
                lowerlid_all.remove(ai)
        
        allloc = eye_socket_all + upperlid_all + lowerlid_all +[inn_conner] +[outconner] +[eyeBallcentoer] + [crunch]
        #print(mirror_section)
        self.eye_mirrorLocator( mirrorSection = mirror_section ,centorLoc = '' , orgPre = org_pre , tarPre = tar_pre , inputLoctors = allloc )
    
    
    
    
    
    
    
    def eye_setting_build(self):
    
        headMesh_org = mc.textField( 'head_model_textField',q=True,text= True )
        head_mesh = str(headMesh_org)+'_bridgeMesh'
        
        if mc.objExists(head_mesh) == False:
            mc.duplicate(headMesh_org , n = head_mesh )
            blendNode = str( headMesh_org ) + '_blendNode'
            
            mc.blendShape( head_mesh , headMesh_org ,n =blendNode )
            mc.setAttr( str(blendNode) + '.' + str(head_mesh) , 1 )
        
        #IfMirror = mc.checkBox( 'eye_mirror',q = True , value = True  )
        
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        eye_socket = mc.textField( 'eye_socket_temLoc_textField',q=True,text = True )
        upperlid = mc.textField( 'eye_upperlid_temLoc_textField',q=True,text = True )
        lowerlid = mc.textField( 'eye_lowerlid_textField',q=True,text = True )
        inn_conner = mc.textField( 'inn_eye_conner_textField',q=True,text = True )
        out_conner = mc.textField( 'out_eye_conner_textField',q=True,text = True )
        eye_center = mc.textField( 'eye_conter_textField',q=True,text = True )
        
        
        local_setting = mc.radioButtonGrp( 'eye_setting_RBG',q=True,sl=True  )
        orgFix = mc.textField( 'eye_Org_text_textField',q=True , text=True )

        replaceFix = mc.textField( 'eye_replace_textField',q=True,text=True )
        
        eyecrunch_lf = mc.textField( 'eye_eyecrunch_textField',q=True,text=True)
        
        
        ##---------------------------------------------------------
        
        parentHeadGrp = pref +  'eye_parentHead'
        donottoutchGrp = pref + 'eye_donottoutch'
        parentStretchGrp = pref +  'eye_parentStretch'
        
        if mc.objExists( parentHeadGrp ) == 0:
            mc.group(em=True, n = parentHeadGrp )
        
        if mc.objExists( donottoutchGrp ) == 0:
            mc.group(em=True, n = donottoutchGrp )
            
        if mc.objExists( parentStretchGrp ) == 0:
            mc.group(em=True, n = parentStretchGrp )
            
            
            
            
        #
        #---------------------------------------------------------

        eye_socket_all = str(eye_socket).split(' ')
        for ai in eye_socket_all:
            if '' == ai:
                eye_socket_all.remove(ai)
                
        upperlid_all = str(upperlid).split(' ')
        for ai in upperlid_all:
            if '' == ai:
                upperlid_all.remove(ai)
                
        lowerlid_all = str(lowerlid).split(' ')
        for ai in lowerlid_all:
            if '' == ai:
                lowerlid_all.remove(ai)
                
        ##---------------------------
        eye_socket_rt = str(eye_socket).replace( orgFix , replaceFix )
        upperlid_rt = str(upperlid).replace( orgFix , replaceFix )
        lowerlid_rt = str(lowerlid).replace( orgFix , replaceFix )
        inn_conner_rt = str(inn_conner).replace( orgFix , replaceFix )
        out_conner_rt = str(out_conner).replace( orgFix , replaceFix )
        eye_center_rt = str(eye_center).replace( orgFix , replaceFix )
        
        
        eye_socket_all_rt = str(eye_socket_rt).split(' ')
        for ai in eye_socket_all_rt:
            if '' == ai:
                eye_socket_all_rt.remove(ai)
                
        upperlid_all_rt = str(upperlid_rt).split(' ')
        for ai in upperlid_all_rt:
            if '' == ai:
                upperlid_all_rt.remove(ai)
                
        lowerlid_all_rt = str(lowerlid_rt).split(' ')
        for ai in lowerlid_all_rt:
            if '' == ai:
                lowerlid_all_rt.remove(ai)
        
        #----------------------------
        eyectrl_lf = pref + 'ac_'+ orgFix +'eye_ctrl'
        uplidctrl_lf = pref + 'ac_'+ orgFix +'upperlid_ctrl'
        lowerlidectrl_lf = pref + 'ac_'+ orgFix +'lowerlid_ctrl'
        eyeballctrl_lf = pref + 'ac_'+ orgFix +'eyeball_ctrl'
        
        eyectrl_rt = pref + 'ac_'+ replaceFix +'eye_ctrl'
        uplidctrl_rt = pref + 'ac_'+ replaceFix +'upperlid_ctrl'
        lowerlidectrl_rt = pref + 'ac_'+ replaceFix +'lowerlid_ctrl'
        eyeballctrl_rt = pref + 'ac_'+ replaceFix +'eyeball_ctrl'
        
        eyecrunch_rt = str(eyecrunch_lf).replace(orgFix , replaceFix)
        #----------------------------
        if local_setting == 1 or local_setting == 3 :
            info_eye_lf = self.create_eye_settings( ifMirror = 0 , prefix = pref , uplidTem = upperlid_all ,lowerlidTem = lowerlid_all, socketTem = eye_socket_all ,inn_conner = inn_conner,out_conner = out_conner ,eye_center = eye_center, eyectrl = eyectrl_lf,uplidctrl = uplidctrl_lf ,lowerlidectrl = lowerlidectrl_lf ,eyeballctrl = eyeballctrl_lf , eyecrunch = eyecrunch_lf )
            #print(upperlid_all)
            mc.parent(info_eye_lf[3][0] , parentHeadGrp )
            mc.parent(info_eye_lf[3][1] , donottoutchGrp )
            mc.parent(info_eye_lf[3][2] , parentStretchGrp )
            
        if local_setting == 2 or local_setting == 3:
            info_eye_rt = self.create_eye_settings( ifMirror = 1 , prefix = pref , uplidTem = upperlid_all_rt ,lowerlidTem = lowerlid_all_rt, socketTem = eye_socket_all_rt ,inn_conner = inn_conner_rt,out_conner = out_conner_rt ,eye_center = eye_center_rt , eyectrl = eyectrl_rt,uplidctrl = uplidctrl_rt ,lowerlidectrl = lowerlidectrl_rt ,eyeballctrl = eyeballctrl_rt , eyecrunch = eyecrunch_rt )
            #print(upperlid_all_rt)
            mc.parent(info_eye_rt[3][0] , parentHeadGrp )
            mc.parent(info_eye_rt[3][1] , donottoutchGrp )
            mc.parent(info_eye_rt[3][2] , parentStretchGrp )
        
        #
        #=====================================================================
        #-----------  link eye connections -------------------------------
        

        #pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        #local_setting = mc.radioButtonGrp( 'eye_setting_RBG',q=True,sl=True  )
        
        uplidAttr_lf = pref + 'ac_lf_upperlid_ctrl.translateY'
        lowlidAttr_lf = pref + 'ac_lf_lowerlid_ctrl.translateY'
        crunchAttr_lf =  pref + 'ac_lf_eyecrunch_ctrl.translateY'
        
        uplidAttr_rt = str(uplidAttr_lf).replace('lf_','rt_')
        lowlidAttr_rt = str(lowlidAttr_lf).replace('lf_','rt_')
        crunchAttr_rt = str(crunchAttr_lf).replace('lf_','rt_')
        
        
        
        
            
            
        
        if local_setting == 1 or local_setting == 3:
        
            uplid_eyeAttrs = self.narmalize_eyeCtrl( ctrlAttr = uplidAttr_lf ,inverse = 0 )
            lowerlid_eyeAttrs = self.narmalize_eyeCtrl( ctrlAttr = lowlidAttr_lf ,inverse = 1 )
            
            bridge_info_lf = self.createEye_crunchExpand_network( crunchCtrlAttr = crunchAttr_lf , upperlid_ctrlAttr = uplid_eyeAttrs[0] , lowerlid_ctrlAttr = lowerlid_eyeAttrs[0] ,narmalValue = 1  )
            
            
            self.setDrivenFrame(  bridge = bridge_info_lf[0] , offsetGrp = [ info_eye_lf[0][0] , info_eye_lf[0][1] ] )
            
            mc.parent( uplid_eyeAttrs[1] , info_eye_lf[3][1] )
            mc.parent( lowerlid_eyeAttrs[1] , info_eye_lf[3][1] )

                
            
        if local_setting == 2 or local_setting == 3:
            uplid_eyeAttrs = self.narmalize_eyeCtrl( ctrlAttr = uplidAttr_rt ,inverse = 0 )
            lowerlid_eyeAttrs = self.narmalize_eyeCtrl( ctrlAttr = lowlidAttr_rt ,inverse = 1 )
            
            bridge_info_rt = self.createEye_crunchExpand_network( crunchCtrlAttr = crunchAttr_rt , upperlid_ctrlAttr = uplid_eyeAttrs[0] , lowerlid_ctrlAttr = lowerlid_eyeAttrs[0] ,narmalValue = 1  )
            
            
            self.setDrivenFrame(  bridge = bridge_info_rt[0] , offsetGrp = [ info_eye_rt[0][0] , info_eye_rt[0][1] ] )
            
            mc.parent( uplid_eyeAttrs[1] , info_eye_rt[3][1] )
            mc.parent( lowerlid_eyeAttrs[1] , info_eye_rt[3][1] )
            
            
        #=====================================================================================
        #-------------------------------  set driven keyFrame  -------------------------------
            
        #self.LZ_setDrivenKey( driverAttr = bridge_info_lf[0] ,drivenAttr = str(info_eye_lf[0][0]) + '' , 0, 0 )
            if local_setting == 1 or local_setting == 3:
                self.setDrivenFrame(  bridge = bridge_info_lf[0] , offsetGrp = [ info_eye_lf[0][0] , info_eye_lf[0][1] ] )
                mc.parent( bridge_info_lf[0] ,  donottoutchGrp )
            if local_setting == 2 or local_setting == 3:
                self.setDrivenFrame(  bridge = bridge_info_rt[0] , offsetGrp = [ info_eye_rt[0][0] , info_eye_rt[0][1] ] )
                mc.parent(  bridge_info_rt[0]  , donottoutchGrp )
            
            

        #=====================================================================================
        #-------------------------------  skinCluster add  -------------------------------
        
        eyeBaseJnt = pref + 'eye_basejnt'
        
        
        
        if mc.objExists(eyeBaseJnt) == 0:
            self.createTransformer( locName = eyeBaseJnt ,position = ( 0,0,0) , rotation = ( 0,0,0) ,type = 'joint',LocPosion = (0,0,0))
            mc.parent(eyeBaseJnt , donottoutchGrp )
        
        
        
        if  local_setting == 1:
            eyejnts = info_eye_lf[1]+[eyeBaseJnt]
            follow_joints = info_eye_lf[5]
        
        if  local_setting == 2:
            eyejnts = info_eye_rt[1]+[eyeBaseJnt]
            follow_joints = info_eye_rt[5]
        if  local_setting == 3:
            eyejnts = info_eye_lf[1] + info_eye_rt[1] + [eyeBaseJnt]
            follow_joints = info_eye_lf[5] +info_eye_rt[5] 
            
        #info_eye_lf[1]
        
        self.skinCluster_add_2_eyeGeo(  headGeo = headMesh_org , skingeo = head_mesh  ,eyeOpenCloseJnts = eyejnts , followJnts = follow_joints )

        #=====================================================================================
        #-------------------------------  wireDeformer add  -------------------------------
        wireMesh = str(head_mesh) + '_eyeScuplt_mesh'
        if mc.objExists(wireMesh) == 0:
            mc.duplicate( head_mesh , n = wireMesh )
            mc.parent( wireMesh , donottoutchGrp )
            
        
        if  local_setting == 1 or local_setting == 3:
            for curves in info_eye_lf[2]  or local_setting == 3: 
            
                node = pref + 'lf_eye_wire_node'
            
                self.wireDeformer_2_eyeGeo(  inputMesh = wireMesh , inputCurve = curves , wire_node = node )
        
        if  local_setting == 2  or local_setting == 3:
        
            for curves in info_eye_rt[2] : 
            
                node = pref + 'rt_eye_wire_node'
            
                self.wireDeformer_2_eyeGeo(  inputMesh = wireMesh , inputCurve = curves , wire_node = node )
                
        #if  local_setting == 3:
        #        
        #    for curves in info_eye_lf[2] : 
        #    
        #        node = pref + 'lf_eye_wire_node'
        #    
        #        self.wireDeformer_2_eyeGeo(  inputMesh = wireMesh , inputCurve = curves , wire_node = node )
        #        
        #    for curves in info_eye_rt[2] : 
        #    
        #        node = pref + 'rt_eye_wire_node'
        #    
        #        self.wireDeformer_2_eyeGeo(  inputMesh = wireMesh , inputCurve = curves , wire_node = node )    
        #
        blend_node_name = head_mesh +'_blendNode'
        self.AppendTarget( targets = [wireMesh] , BlendMesh = head_mesh ,blendshape_node = blend_node_name )
        mc.setAttr(str(blend_node_name)+'.'+wireMesh , 1)
        
        parent_grp = mc.listRelatives( wireMesh , p=True)
        if parent_grp == None:
            mc.parent( wireMesh , donottoutchGrp )
        
        #=====================================================================================
        #-------------------------------  blendShape add  -------------------------------
        #orgFix , replaceFix
        if local_setting == 1 or  local_setting == 3:
            #lfBridge = bridge_info_lf
            self.eye_blendShape_settings( inputMesh = head_mesh , locPre = orgFix, prefix = pref , bridge = bridge_info_lf[0] , open_uplid_Attr = 'upperlid_open' , close_uplid_Attr = 'upperlid_close', open_lowerlid_Attr = 'lowerlid_open' , close_lowerlid_Attr = 'lowerlid_close' ,crunchAttr = 'crunch' , expandAttr = 'expand')
            
        if local_setting == 2 or  local_setting == 3:
            
            self.eye_blendShape_settings( inputMesh = head_mesh , locPre = replaceFix, prefix = pref , bridge = bridge_info_rt[0] , open_uplid_Attr = 'upperlid_open' , close_uplid_Attr = 'upperlid_close', open_lowerlid_Attr = 'lowerlid_open' , close_lowerlid_Attr = 'lowerlid_close' ,crunchAttr = 'crunch' , expandAttr = 'expand')
        
        
        ##====
        
        
    #=====================================================================================
    #-------------------------------  mouth secondry control reset  -------------------------------
    
    def resetMouthCtrlPosition(self):
        
        pref = mc.textField( 'charator_prefix_textField',q=True ,text=True )
        self.disconnect_ctrlsetting( prefix = pref )
        
        
    def loadHeadMesh(self):
        
        self.loadTextField( 'head_model_textField' )
        
        objsel = mc.ls(sl=True)[0]
        blendMesh = str(objsel)+'_bridgeMesh'
        skinMesh = 'mouth_Scuplt_mesh'
        mc.textField( 'nose_skinMesh_textField',e=True , text=skinMesh )
        mc.textField( 'nose_BlendMesh_textField',e=True ,text = blendMesh )